package com.oocl.customer.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.customersystem.pojo.Order;
import com.oocl.customersystem.util.RequestUtil;


public class FindOrders extends HttpServlet {
	private static final long serialVersionUID = 1L;

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Map<String,Order> cart = (Map<String, Order>) request.getSession().getAttribute("cart");
		List<Order> list =new  ArrayList<Order>();
		if(null!=cart){
			Set<String> set = cart.keySet();
			for(String fname:set){
				list.add(cart.get(fname));
			}
			
		}
		String json = RequestUtil.wrapToJson(list);
		response.setContentType("application/json;charset=utf-8");
		response.getWriter().write(json);
	}

}
